package com.ypx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ypx.bean.Employee;
import com.ypx.exception.CustomException;
import com.ypx.service.EmployeeService;
import com.ypx.mapper.EmployeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 易鹏祥
* @description 针对表【employee(员工信息)】的数据库操作Service实现
* @createDate 2023-05-23 16:18:30
*/
@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService{

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public Employee findByUsername(String username) {
        return employeeMapper.findByUsername(username);
    }

//    @Override
//    public Page<Employee> page(Integer page, Integer pageSize, String name) {
//        Page<Employee> employeePage = new Page<>(page, pageSize);
//        List<Employee> employees = employeeMapper.list(employeePage, name);
//        employeePage.setRecords(employees);
//        return employeePage;
//    }

    @Override
    public int countByUsernameNotSelf(String username, Long id) {
        return baseMapper.countByUsernameNotSelf(username, id);
    }

    @Override
    public boolean updateEmployee(Employee employee) {
        return updateById(employee);
    }

}




